<template>
  <div>
    <h1>登录</h1>
    <!-- 验证码 -->
    <img :src="img"  @click="getVeriCode">
  </div> 
</template>
<script>
export default {
  name: 'Login',
  data() {
    return {
      img:"",//base64位字符串的图片
      uuid:""//随机字符串
    }
  },
  created() {
     this.getVeriCode();
  },
  methods:{
    getVeriCode(){ //获取验证码
       this.$axios({ //调用接口
        url:"/ruoyi/captchaImage",
        method:"get"
       }).then(res=>{
        console.log(res,"获取验证码")
          this.img="data:image/png;base64,"+res.data.img; //存储验证码
          this.uuid=res.data.uuid;//存储随机字符串
       }).catch(err=>{
        console.log(err,"错误信息")
       })

    }
  }
}
</script>